<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>后台</title>
		<link href="../css/bootstrap.min.css" rel="stylesheet" />
		<link href="../css/material-dashboard.css" rel="stylesheet" />
		<script src="../js/jquery-3.2.1.min.js"></script>
		<style>
			.form-control1 {
				width: 70%;
				height: 34px;
				font-size: 14px;
				line-height: 1.42857143;
				color: #555555;
				background-color: #fff;
				background-image: none;
				border: 1px solid #ccc;
				border-radius: 4px;
				transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
			}

			.form-control1:focus {
				border-color: #66afe9;
				outline: 0;
				-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
				box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
			}

			.sidebar[data-color="purple"] .nav li.active a,
			.off-canvas-sidebar[data-color="purple"] .nav li.active a {
				background-color: #0c8687;
				box-shadow: 0 12px 20px -10px rgba(0, 190, 139, 0.3), 0 4px 20px 0px rgba(0, 208, 153, 0.1), 0 7px 8px -5px rgba(0, 153, 112, 0.2);
			}

			.modal-body button {
				width: 100px;
				height: 100px;
				border-radius: 50%;
				margin: 20px;
			}

			.aui-info {
				position: relative;
				width: 400px;
				height: auto;
				text-align: center;
				margin: 0 auto;
			}

			.aui-img-round {
				width: 100px;
				height: 100px;
				border-radius: 50%;
				border: 1px #ccc solid;
			}

			.fileInput {
				width: 6.25rem;
				height: 100px;
				position: absolute;
				top: 0;
				/* bottom: 300px; */
				left: 0;
				right: 0;
				opacity: 0;
				display: block;
				width: 100px;
				clear: both;
				display: block;
				margin: auto;
				background-color: red;
			}

			.info1 {
				width: 500px;
				margin-top: 15px;
				height: 180px;
				text-align: center;
			}

			.info1 div {
				float: left;
				width: 250px;
				height: 60px;
			}
		</style>
		<style>
			/* 分页 */
			.page-container a,
			.page-container a:hover {
				color: #0c8687;
				font-size: 14px;
				text-decoration: none;
			}

			.pagination>.active>a,
			.pagination>.active>span,
			.pagination>.active>a:hover,
			.pagination>.active>span:hover,
			.pagination>.active>a:focus,
			.pagination>.active>span:focus {
				z-index: 3;
				color: #fff;
				cursor: default;
				background-color: #0c8687;
				border-color: #0c8687;
			}

			.pagination>li>a {
				color: rgb(187, 187, 187);
			}

			.pagination input {
				outline: none;
				border-radius: 4px;
				width: 60px;
				height: 34px;
				outline: none;
				border: 1px #DDDDDD solid;
				text-align: center;
			}

			#go-page,
			#go-page1 {
				border: 1px #0c8687 solid;
				color: #fff;
				background: #0c8687;
			}

			/* 表格 */
			.tablelist {
				width: 100%;
				height: auto;
				/* border: 1px #0c8687 solid; */
				margin-top: 70px;
			}

			.table-user {
				width: 90%;
				border-collapse: collapse;
				margin: 0 auto;
			}

			.table-user caption {
				/* font-size: 2em; */
				font-weight: bold;
				/* margin: 1em 0; */
			}

			.table-user caption div {
				float: right;
			}

			.table-user caption input {
				width: 260px;
				height: 36px;
				color: #0c8687;
				border: 1px #0c8687 solid;
				border-radius: 5px;
			}

			th,
			td {
				border: 1px solid #ddddddc9;
				text-align: center;
				/* padding: 10px 0; */
			}

			.table-user thead tr {
				background-color: #008c8c;
				color: #fff;
			}

			.table-user thead tr th {
				padding: 10px 0;
			}

			.table-user tbody tr:nth-child(odd) {
				background-color: #eee;
			}

			.table-user tbody tr:hover {
				background-color: #0c868773;
			}

			.table-user tbody tr td:first-child {
				color: #0c8687;
			}

			.table-user tfoot tr td {
				text-align: right;
				padding-right: 20px;
				border: none;
			}

			.pull-left li a:hover {
				background-color: #0c8687;
				border-radius: 30px;
				color: #fff;
			}

			.found {
				display: none;
			}

			.choose-seek {
				background-color: #0c8687;
				border-radius: 30px;
				color: #fff;
			}
		</style>
	</head>
	<body>
		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
			aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header" style="border-bottom: 2px #ddd solid;">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title" id="messagetitle" data-toggle="modal" data-target="#messageBox">显示
						</h4>
					</div>
					<div class="modal-body" style="text-align: center;">
						<form name="saveMessage">
							<button class="btn btn-info" data-dismiss="modal">个人资料</button>
							<button class="btn btn-danger" id="over">退出</button>
						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn-flat pull-right close-notice btn btn-default"
							style="margin-right: 20px;" data-dismiss="modal">关闭</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal -->
		</div>

		<!-- 模态框（Modal）   个人资料显示 -->
		<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
								aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="gridSystemModalLabel">资料显示</h4>
					</div>
					<div class="modal-body">
						<form action="#" method="post" enctype="multipart/form-data">
							<div class="aui-info">
								<img src="../images/6.jpg" id="img-txz"
									style="width: 100px;height: 100px;border-radius: 50%;"
									class="aui-img-round user-img" />
								<input type="file" accept="image/*" id="file-txz" name="file"
									onchange="upload('#file-txz', '#img-txz');" class="fileInput" value="" />
							</div>
							<div class="aui-info info1">
								<div>
									<span>用户名：<input type="text" id="username" class="form-control1"
											value="柠檬" /></span>
								</div>
								<div>
									<span>性别：<input type="text" id="sex" class="form-control1" value="女" /></span>
								</div>
								<div>
									<span>邮箱：<input type="text" id='email' class="form-control1"
											value="123@qq.com" /></span>
								</div>
								<div>
									<span>手机号码：<input type="text" id="phone" class="form-control1"
											value="17375212967" /></span>
								</div>
								<div>
									<span>生日：<input type="text" id="born" class="form-control1"
											value="2002-11-11" /></span>
								</div>
								<div>
									<span class="has-success">地址：<input type="text" id="adrs"
											class="form-control1 input-success" value="湖南省长沙市开福区" /></span>
								</div>

							</div>
						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal"
							style="width: 90px;">取消</button>
						<button type="button" class="btn btn-primary update" style="width: 90px;">修改</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->

		<!-- 模态框（Modal）   寻宠物详情 -->
		<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
								aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="gridSystemModalLabel">寻宠物</h4>
					</div>
					<div class="modal-body">
						<form action="#" method="post" enctype="multipart/form-data">
							<div class="aui-info">
								<img src="../images/pet-avatar.png" id="img-xcw" class="aui-img-round user-img" />
								<input type="file" accept="image/*" id="file-xcw" name="file"
									onchange="upload('#file-xcw', '#img-xcw');" class="fileInput" value="" />
							</div>

							<div class="aui-info info1 info2">
								<div>
									<span>发布标题：<input type="text" disabled id="stitle" class="form-control1"
											value="" />
									</span>					
								</div>
								<div>
									<span>宠物名称：<input type="text" disabled id="upname" class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>失主：<input type="text" id="suser" disabled class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>丢失地址：<input type="text" id='saddress' disabled class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>丢失日期：<input type="text" id="sdate" disabled class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>联系电话：<input type="text" id="sphone" disabled class="form-control1"
											value="" /></span>
								</div>
							</div>
							<div class="aui-info"
								style="width: 500px;height: 105px;position: relative;text-align: right;">
								<span style="position: absolute;top: 10px;left: 0;">详情描述：</span>
								<textarea style="width: 86%;height: 70px;" disabled
									class="form-control1 sdesc"></textarea>
							</div>
						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal"
							style="width: 90px;">取消</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->

		<!-- 模态框（Modal）   找主人详情 -->
		<div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
								aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="gridSystemModalLabel">找主人</h4>
					</div>
					<div class="modal-body">
						<form action="#" method="post" enctype="multipart/form-data">
							<div class="aui-info">
								<img src="../images/pet-avatar.png" id="img-zzr" class="aui-img-round user-img" />
								<input type="file" accept="image/*" id="file-zzr" name="file"
									onchange="upload('#file-zzr', '#img-zzr');" class="fileInput" value="" />
							</div>

							<div class="aui-info info1 info2">
								<div>
									<span>发布标题：<input type="text" disabled  id="ftitle" class="form-control1"
											value="" />
									</span>
								</div>
								<div>
									<span>宠物品种：<input type="text" disabled id="petpz" class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>发布用户：<input type="text" id="fuser" disabled class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>拾到地址：<input type="text" id='faddress' disabled class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>拾到日期：<input type="text" id="fdate" disabled class="form-control1"
											value="" /></span>
								</div>
								<div>
									<span>联系电话：<input type="text" id="fphone" disabled class="form-control1"
											value="" /></span>
								</div>
							</div>
							<div class="aui-info"
								style="width: 500px;height: 105px;position: relative;text-align: right;">
								<span style="position: absolute;top: 10px;left: 0;">详情描述：</span>
								<textarea style="width: 86%;height: 70px;" disabled
									class="form-control1 fdesc"></textarea>
							</div>
						</form>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal"
							style="width: 90px;">取消</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->


		<div class="wrapper">
			<div class="sidebar" data-color="purple" data-image="../assets/img/sidebar-1.jpg">
				<div class="logo" style="background-color: #0c8687;width: 260px;height: 70px;">
					<a href="#" class="simple-text" style="color: #fff;">
						<img src="../images/logo-pet2.png" style="position: absolute;top: -60px;left: 0px;"/>
					</a>
				</div>
				<div class="sidebar-wrapper">
					<ul class="nav">
						<li>
							<a href="usermanager.html">
								<p>用户管理</p>
							</a>
						</li>
						<li>
							<a href="adminpetbrand.html">
								<p>品种管理</p>
							</a>
						</li>
						<li>
							<a href="petinfo.html">
								<p>信息管理</p>
							</a>
						</li>
						<li class="active">
							<a href="finder.html">
								<p>寻宠、招领管理</p>
							</a>
						</li>
						<li>
							<a href="bbscomment.html">
								<p>论坛、评论管理</p>
							</a>
						</li>
						<li>
							<a href="fostercare.html">

								<p>领养、寄养管理</p>
							</a>
						</li>

					</ul>
				</div>
			</div>

			<div class="main-panel">
				<nav class="navbar navbar-transparent navbar-absolute" style="background-color: #0c8687;height: 70px;">
					<div class="container-fluid">
						<div class="collapse navbar-collapse">
							<ul class="nav navbar-nav navbar-right">
								<li>
									<button class="btn btn-default" data-toggle="modal" data-target="#myModal"
										style="width: 56px;height: 56px;border-radius: 50%;position: relative;background-color: #fff;">
										<img src="../images/c1.jpg" class="img-tx"
											style="width: 56px;height: 56px;border: 1px #fff solid;border-radius: 50%;position: absolute;top: 0px;right: 2px;" />
									</button>
								</li>
							</ul>


						</div>
					</div>
				</nav>
				<div class="tablelist">
					<table class="table-user">
						<caption>
							<ul class="nav nav-pills pull-left">
								<li>
									<a href="javascript:void(0)" class="choose-seek" style="color: #fff">寻宠物</a>
								</li>
								<li>
									<a href="javascript:void(0)" class="choose-find"
										style="color: rgb(27, 36, 47);background-color: #dddddd9c;">找主人</a>
								</li>
							</ul>
							<div class="div1">
								<input type="text" class="input-success seekinfo" />
								<button class="btn btn-info btn-sm cxseek">查询</button>
							</div>
							<div class="div2" style="display: none;">
								<input type="text" class="input-success foundinfo" />
								<button class="btn btn-info btn-sm cxfound">查询</button>
							</div>
						</caption>
						<thead class="seek">
							<tr>
								<th>寻宠编号</th>
								<th>发布标题</th>
								<th>宠物照片</th>
								<th>丢失地址</th>
								<th>丢失日期</th>
								<th>联系电话</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody class="seek seek1">
							<tr>
								<td>1</td>
								<td>呜呜呜，我丢失了我的宝贝</td>
								<td><img src="../images/6.jpg" width="45px" /></td>
								<td>柠檬</td>
								<td>丢咔咩</td>
								<td>长沙市开福区</td>
								<td>2022-11-11</td>
								<td>17376546783</td>
								<td>
									<button class="btn btn-info btn-sm" data-toggle="modal"
										data-target="#myModal3">详情</button>
									<button class="btn btn-danger btn-sm deladmin">删除</button>
								</td>
							</tr>
						</tbody>
						<thead class="found">
							<tr>
								<th>招领编号</th>
								<th>发布标题</th>
								<th>宠物照片</th>
								<th>拾到地址</th>
								<th>拾到日期</th>
								<th>联系电话</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody class="found found1">
							<tr>
								<td>2</td>
								<td>不小心捡到了谁的小宝贝</td>
								<td><img src="../images/6.jpg" width="45px" /></td>
								<td>柠檬</td>
								<td>丢咔咩</td>
								<td>长沙市开福区</td>
								<td>2022-11-11</td>
								<td>17376546783</td>
								<td>
									<button class="btn btn-info btn-sm" data-toggle="modal"
										data-target="#myModal4">详情</button>
									<button class="btn btn-danger btn-sm deladmin">删除</button>
								</td>
							</tr>
						</tbody>
						<tfoot>
							<tr>
								<td colspan="10">
									<div class="text-center hidden-xs" style="margin-left: 256px;text-align: right;">
										<ul class="pagination page1">
											<li class="active"><a href="javascript:void(0)" id="firstpage"
													title="首页">首页</a></li>
											<li><a href="javascript:void(0)" id="prevpage" title="上一页">上一页</a></li>
											<li><a href="javascript:void(0)" id="nextpage" title="下一页">下一页</a></li>
											<li><a href="javascript:void(0)" id="lastpage" title="最后一页">尾页</a></li>
											<li style="margin-left: 20px;">第<input type="text" id="pagenum"
													value="1" />页
												<input type="button" value="GO" id="go-page" style="" />
											</li>
										</ul>
										<ul class="pagination page2" style="display: none;">
											<li class="active"><a href="javascript:void(0)" id="firstpage1"
													title="首页">首页</a></li>
											<li><a href="javascript:void(0)" id="prevpage1" title="上一页">上一页</a></li>
											<li><a href="javascript:void(0)" id="nextpage1" title="下一页">下一页</a></li>
											<li><a href="javascript:void(0)" id="lastpage1" title="最后一页">尾页</a></li>
											<li style="margin-left: 20px;">第<input type="text" id="pagenum1"
													value="1" />页
												<input type="button" value="GO" id="go-page1" style="" />
											</li>
										</ul>
									</div>
								</td>
							</tr>
						</tfoot>
					</table>
				</div>

			</div>

	</body>

	<!--   Core JS Files   -->
	<script src="../js/jquery-3.1.0.min.js" type="text/javascript"></script>
	<script src="../js/bootstrap.min.js" type="text/javascript"></script>
	<script src="../js/material.min.js" type="text/javascript"></script>
	<script src="../js/chartist.min.js"></script>
	<script src="../js/material-dashboard.js"></script>
	<script type="text/javascript" src="../js/plugs.js">
	</script>
	<script type="text/javascript">
		$(function() {
			$('#myModal').on('hidden.bs.modal', function() {
				//模态框关闭时执行
				$("#myModal2").modal('show');
			});
			$("#over").click(function() {
				if (!confirm("是否确定退出后台？")) {
					return;
				}
				location.href = 'http://localhost/pet/page/login.html';
			})

		})
	</script>
	<!-- 图片上传预览 -->
	<script type="text/javascript">
		var upload = function(c, d) {
			"use strict";
			var $c = document.querySelector(c),
				$d = document.querySelector(d),
				file = $c.files[0],
				reader = new FileReader();
			reader.readAsDataURL(file);
			reader.onload = function(e) {
				$d.setAttribute("src", e.target.result);
			};
		};
	</script>
	<!-- 点击切换 -->
	<script>
		$(function() {
			// 换页
			$(".pagination li").click(function() {
				$(this).children("a").css("color", "#fff");
				$(this).children("a").css("cursor", "default");
				$(this).children("a").css("background-color", "#0c8687");
				$(this).children("a").css("border-color", "#0c8687");
				$(this).siblings().children("a").css("color", "#bbb");
				$(this).siblings().children("a").css("cursor", "default");
				$(this).siblings().children("a").css("background-color", "#fff");
				$(this).siblings().children("a").css("border-color", "#ddd");

			})
			//点击切换
			$(".pull-left li a").click(function() {
				$(this).css("background-color", "#0c8687").css("border-radius", "30px").css("color", "#fff");
				$(this).parent("li").siblings().children().css("background-color", "#dddddd9c").css("color",
					"rgb(27, 36, 47)");
			})
			$(".choose-find").click(function() {
				$(".found").css("display", "table-row-group");
				$(".seek").css("display", "none");
				$(".div2").css("display", "block");
				$(".div1").css("display", "none");
				$(".page2").css("display", "inline-block");
				$(".page1").css("display", "none");
			})
			$(".choose-seek").click(function() {
				$(".found").css("display", "none");
				$(".seek").css("display", "table-row-group");
				$(".div2").css("display", "none");
				$(".div1").css("display", "block");
				$(".page2").css("display", "none");
				$(".page1").css("display", "inline-block");
			})
		})
	</script>

	<!-- 修改用户  验证  注销-->
	<script>
		$(function() {
			$('#myModal').on('hidden.bs.modal', function() {
				//模态框关闭时执行
				$("#myModal2").modal('show');
			});
			//注销
			$("#over").click(function(event) {
				event.preventDefault();
				if (!confirm("是否确定退出后台？")) {
					return;
				}
				$.post('http://localhost:80/ct/overuser', function(r) {
					if (r) {
						location.href = 'login.html';
					}
				}, "json");

			})
			//显示管理员信息
			admininfo();

			function admininfo() {
				$.post('http://localhost:80/ct/admindetail', function(r) {
					$(".img-tx").attr("src", "../images/" + r.filename + "");
					$("#img-txz").attr("src", "../images/" + r.filename + "");
					$("#username").val(r.username);
					$("#sex").val(r.sex);
					$("#phone").val(r.phone);
					$("#born").val(r.borndate);
					$("#adrs").val(r.faddress);
					$("#email").val(r.email);
				}, "json");
			}

			//修改管理员信息
			$(".update").click(function() {
				let user = $("#username").val();
				let sex = $("#sex").val();
				let phone = $("#phone").val();
				let adrs = $("#adrs").val();
				let born = $("#born").val();
				let email = $("#email").val();
				//非空验证
				if (user == '' || sex == '' || born == '' || phone == '' || adrs == '' || email == '') {
					if (user == '') {
						$("#username").css("border-color", "#a94442").css("box-shadow",
							"inset 0 1px 1px rgba(0,0,0,.075)");
					}
					if (sex == '') {
						$("#sex").css("border-color", "#a94442").css("box-shadow",
							"inset 0 1px 1px rgba(0,0,0,.075)");
					}
					if (born == '') {
						$("#born").css("border-color", "#a94442").css("box-shadow",
							"inset 0 1px 1px rgba(0,0,0,.075)");
					}
					if (phone == '') {
						$("#phone").css("border-color", "#a94442").css("box-shadow",
							"inset 0 1px 1px rgba(0,0,0,.075)");
					}
					if (adrs == '') {
						$("#adrs").css("border-color", "#a94442").css("box-shadow",
							"inset 0 1px 1px rgba(0,0,0,.075)");
					}
					if (email == '') {
						$("#email").css("border-color", "#a94442").css("box-shadow",
							"inset 0 1px 1px rgba(0,0,0,.075)");
					}
					alert("修改信息不能为空！");
					return;
				}
				if (sex != '男' && sex != '女') {
					alert("性别只能为男或女！");
					return false;
				}
				//手机格式验证
				var telStr = /^[1]([3-9])[0-9]{9}$/;
				if (!(telStr.test(phone))) {
					alert("手机格式不规范！");
					$("#phone").css("border-color", "#a94442").css("box-shadow",
						"inset 0 1px 1px rgba(0,0,0,.075)");
					return;
				}
				//邮箱验证
				var yx = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
				if (!(yx.test(email))) {
					alert("邮箱格式不规范！");
					$("#email").css("border-color", "#a94442").css("box-shadow",
						"inset 0 1px 1px rgba(0,0,0,.075)");
					return;
				}

				var formData = new FormData();
				formData.append("sex", sex);
				formData.append("phone", phone);
				formData.append("email", email);
				formData.append("username", user);
				formData.append("adrs", adrs);
				formData.append("borndate", born);
				let f = document.getElementById('file-txz');
				let f1 = f.files[0];
				// 判断是否选择上传图片
				if ($("#file-txz").val() == '') {
					//不上传	
					$.post('http://localhost:80/ct/upadmin2', {
						"sex": sex,
						"phone": phone,
						"email": email,
						"username": user,
						"adrs": adrs,
						"borndate": born
					}, function(r) {
						if (r) {
							alert("修改成功！");
						} else {
							alert("修改失败！");
						}
						location.href = 'petinfo.html';
					}, "json");
				} else {
					formData.append("files", f1);
					$.ajax({
						url: 'http://localhost:80/ct/upadmin1',
						type: 'post',
						data: formData,
						contentType: false,
						processData: false,
						success: function(res) {
							if (res) {
								alert("修改成功！");
							} else {
								alert("修改失败！");
							}
							location.href = 'petinfo.html';
						}
					})
				}

			})

		})
	</script>


	<script type="text/javascript">
		$(function() {
			let index = 1;
			let index1 = 1;
			let pages = 1;
			let pages1 = 1;

			$(".cxseek").click(function() {
				index = 1;
				$("#pagenum").val(index);
				seekall();
			})
			$("#prevpage").click(function() {
				if (index > 1) {
					index = index - 1;
				} else {
					alert("当前页已是第一页！");
					index = index;
				}
				$("#pagenum").val(index);
				seekall();
			})
			$("#nextpage").click(function() {
				if (index < pages) {
					index = index + 1;
				} else {
					alert("当前页已是最后一页！");
					index = index;
				}
				$("#pagenum").val(index);
				seekall();
			})
			$("#lastpage").click(function() {
				index = pages;
				$("#pagenum").val(index);
				seekall();
			})
			$("#firstpage").click(function() {
				index = 1;
				$("#pagenum").val(index);
				seekall();
			})
			$("#go-page").click(function() {
				let pagenum = $("#pagenum").val();
				if (pagenum > pages) {
					alert("输入页码不能大于总页数！");
					index = index;
				} else {
					if (pagenum <= 0) {
						alert("输入页码不能小于1！");
						index = index;
					} else {
						index = pagenum;
					}
				}
				$("#pagenum").val(index);
				seekall();
			})

			seekall();

			function seekall() {
				$.post('http://localhost:80/ct/seekall2', {
					"index": index,
					"address": $(".seekinfo").val()
				}, function(r) {
					$(".seek1").children().remove();
					$(r.records).each(function(i, e) {
						let trs = "<tr>" +
							"<td>" + (i + 1) + "</td>" +
							"<td>" + e.seektitle + "</td>" +
							"<td><img src='../images/" + e.seekfile + "' width='45px' /></td>" +
							"<td>" + e.seekaddress + "</td>" +
							"<td>" + e.seekdate + "</td>" +
							"<td>" + e.seekphone + "</td>" +
							"<td>" +
							"<button class='btn btn-info btn-sm' data-toggle='modal' onclick='seekdesc(" +
							e.seekid + ")' data-target='#myModal3'>详情</button>" +
							"<button class='btn btn-danger btn-sm' onclick='delseek("+e.seekid+")'>删除</button>" +
							"</td>" +
							"</tr>";
						$(".seek1").append(trs);
					})
					pages = r.pages;
				}, "json");
			}

			$(".cxfound").click(function() {
				index1 = 1;
				$("#pagenum1").val(index1);
				foundall();
			})
			$("#prevpage1").click(function() {
				if (index1 > 1) {
					index1 = index1 - 1;
				} else {
					alert("当前页已是第一页！");
					index1 = index1;
				}
				$("#pagenum1").val(index1);
				foundall();
			})
			$("#nextpage1").click(function() {
				if (index1 < pages1) {
					index1 = index1 + 1;
				} else {
					alert("当前页已是最后一页！");
					index1 = index1;
				}
				$("#pagenum1").val(index1);
				foundall();
			})
			$("#lastpage1").click(function() {
				index1 = pages1;
				$("#pagenum1").val(index1);
				foundall();
			})
			$("#firstpage1").click(function() {
				index1 = 1;
				$("#pagenum1").val(index1);
				foundall();
			})
			$("#go-page1").click(function() {
				let pagenum = $("#pagenum1").val();
				if (pagenum > pages1) {
					alert("输入页码不能大于总页数！");
					index1 = index1;
				} else {
					if (pagenum <= 0) {
						alert("输入页码不能小于1！");
						index1 = index1;
					} else {
						index1 = pagenum;
					}
				}
				$("#pagenum1").val(index1);
				foundall();
			})

			foundall();

			function foundall() {
				$.post('http://localhost:80/ct/foundall2', {
					"index": index1,
					"address": $(".foundinfo").val()
				}, function(r) {
					$(".found1").children().remove();
					$(r.records).each(function(i, e) {
						let trs = "<tr>" +
							"<td>" + (i + 1) + "</td>" +
							"<td>" + e.foundtitle + "</td>" +
							"<td><img src='../images/" + e.foundfile + "' width='45px' /></td>" +
							"<td>" + e.foundaddress + "</td>" +
							"<td>" + e.founddate + "</td>" +
							"<td>" + e.foundphone + "</td>" +
							"<td>" +
							"<button class='btn btn-info btn-sm' data-toggle='modal' onclick='founddesc("+e.fid+")' data-target='#myModal4'>详情</button>" +
							"<button class='btn btn-danger btn-sm' onclick='delfound("+e.fid+")' >删除</button>" +
							"</td>" +
							"</tr>";
						$(".found1").append(trs);
					})
					pages1 = r.pages;
				}, "json");
			}
		})
		//寻宠详情
		function seekdesc(id) {
			$.post('http://localhost:80/ct/seekone', {
				"seekid": id
			}, function(r) {
				$("#img-xcw").attr("src","../images/"+r.seekfile+"");
				$("#stitle").val(r.seektitle);	
				$("#saddress").val(r.seekaddress);
				$("#sdate").val(r.seekdate);
				$("#sphone").val(r.seekphone);
				$(".sdesc").val(r.seekdetail);
				$.post('http://localhost:80/ct/userdetail', {
					"uid": r.s_uid
				}, function(r) {
					$("#suser").val(r.username);
				}, "json");
				$.post('http://localhost:80/ct/petdetail', {
					"upid": r.s_upid
				}, function(r) {
					$("#upname").val(r.upname);
				}, "json");
			}, "json");
		}
		//删除寻宠
		function delseek(id) {
			if (!confirm("是否确定删除该信息？"))
				return;
			$.post('http://localhost:80/ct/delseekone', {
				"seekid": id
			}, function(r) {
				if (r) {
					alert("删除成功！");
				} else {
					alert("删除失败");
				}
				location.href = 'finder.html';
			}, "json");
		}
		//招领详情
		function founddesc(fid) {
			$.post('http://localhost:80/ct/foundone', {
				"fid": fid
			}, function(r) {
				$("#img-zzr").attr("src","../images/"+r.foundfile+"");
				$("#ftitle").val(r.foundtitle);
				$("#faddress").val(r.foundaddress);
				$("#fdate").val(r.founddate);
				$("#fphone").val(r.foundphone);
				$(".fdesc").val(r.founddetail);

				$.post('http://localhost:80/ct/userdetail', {
					"uid": r.f_uid
				}, function(r) {
					$("#fuser").val(r.username);
				}, "json");
				$.post('http://localhost:80/ct/petinfoOne', {
					"bid": r.f_bid
				}, function(r) {
					$("#petpz").val(r.bname);
				}, "json");
			}, "json");
		}
		//删除招领
		function delfound(id) {
           if(!confirm("是否确定删除该信息？"))
           return;
           $.post('http://localhost:80/ct/delfoundone',{"fid":id},function(r){
           	if(r){
           					alert("删除成功！");
           				}else{
           					alert("删除失败");
           				}
           				location.href='finder.html';
           },"json");
		}
	</script>
</html>